package skyinline.swing;

import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

public class SwingToolBar extends JToolBar {

	private static SwingMenuActionListener action = null;
	
	private String imgPath = "/images/toolbar/";
	private String imgExt = ".png";
			
	public SwingToolBar() {
		action = new SwingMenuActionListener();
		setFloatable ( false );
		addToolBarButton();
	}
	
	public void addToolBarButton() {
		add ( makeToolBarButton("new", "새로 만들기") );
		add ( makeToolBarButton("close", "닫기") );
		add ( makeToolBarButton("exit", "프로그램 종료") );
		add ( makeToolBarButton("about", "프로그램 정보") );
	}
	
	private JButton makeToolBarButton(String img, String tooltip) {
		JButton btn = new JButton();
		btn.setFocusable(false);
		btn.addActionListener(action);
		btn.setActionCommand(img);
		btn.setToolTipText("tooltip");
		
		URL iconPath = getClass().getResource( imgPath + img + imgExt );
		btn.setIcon(new ImageIcon(iconPath));
		return btn;
	}
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
	
}
